package com.neuedu.api;

import java.util.HashSet;
import java.util.Set;

public class MyObject {
    public static void main(String[] args) {

        Object obj = new Object();
        Person peron = new Person();
        Person peron2 = new Person();

        Class clazz = obj.getClass();

        //输出对象调用的是对象的  toString方法
//        clazz.toString()
        System.out.println("obj.getClass() = " + clazz);
        System.out.println("peron.getClass() = " + peron);

        System.out.println("peron.equals(peron):   " + peron.equals(peron));
        System.out.println("peron.equals(peron2):   " + peron.equals(peron2));


        Human h1 = new Human(50);
        Human h2 = new Human(50);


        System.out.println("h1 == h2 " + (h1 == h2));
        System.out.println("h1.equals(h2) : " + h1.equals(h2));

        String str1 = new String("abc");
        String str2 = new String("abc");

        System.out.println("(str1 == str2) = " + (str1 == str2));
        System.out.println("str1.equals(str2) = " + str1.equals(str2));


        //无需，不可以重复
        Set set = new HashSet();

        set.add(peron);
        set.add(peron2);
        set.add(h1); //hashcode   equals
        set.add(h2);

        System.out.println("set.size() = " + set.size());

    }
}
